package cn.stylefeng.guns.modular.deduct.controller;

import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.modular.deduct.entity.Deduct;
import cn.stylefeng.guns.modular.deduct.model.params.DeductParam;
import cn.stylefeng.guns.modular.deduct.service.DeductService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.kernel.model.response.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 扣费记录表控制器
 *
 * @author liuqiang
 * @Date 2020-02-09 11:12:51
 */
@RestController
@RequestMapping("/deduct")
public class DeductController extends BaseController {

    @Autowired
    private DeductService deductService;


    /**
     * 新增接口
     *
     * @author liuqiang
     * @Date 2020-02-09
     */
    @PostMapping("/addItem")
    public ResponseData addItem(@RequestBody DeductParam deductParam) {
        this.deductService.add(deductParam);
        return ResponseData.success();
    }

    /**
     * 编辑接口
     *
     * @author liuqiang
     * @Date 2020-02-09
     */
//    @RequestMapping("/editItem")
//    @ResponseBody
    public ResponseData editItem(DeductParam deductParam) {
        this.deductService.update(deductParam);
        return ResponseData.success();
    }

    /**
     * 删除接口
     *
     * @author liuqiang
     * @Date 2020-02-09
     */
//    @RequestMapping("/delete")
//    @ResponseBody
    public ResponseData delete(@RequestBody DeductParam deductParam) {
        this.deductService.delete(deductParam);
        return ResponseData.success();
    }

    /**
     * 查看详情接口
     *
     * @author liuqiang
     * @Date 2020-02-09
     */
//    @RequestMapping("/detail")
//    @ResponseBody
    public ResponseData detail(DeductParam deductParam) {
        Deduct detail = this.deductService.getById(deductParam.getId());
        return ResponseData.success(detail);
    }

    /**
     * 查询列表
     *
     * @author liuqiang
     * @Date 2020-02-09
     */
    @GetMapping("/list")
    public LayuiPageInfo list(DeductParam deductParam) {
        return this.deductService.findPageBySpec(deductParam);
    }

}


